package com.bookbuf.cardflipanimation.sample;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.bookbuf.cardflipanimation.CardBackFragment;
import com.bookbuf.cardflipanimation.R;

/**
 * Created by robert on 16/7/6.
 */
public class Fragment111 extends FragmentSample {
	@Override
	String init () {
		return "111";
	}

	@Override
	int color () {
		return getResources ().getColor (android.R.color.holo_blue_bright);
	}

	@Override
	public void onViewCreated (View view, @Nullable Bundle savedInstanceState) {
		super.onViewCreated (view, savedInstanceState);
		view.setOnClickListener (new View.OnClickListener () {
			@Override
			public void onClick (View v) {
				flip ();
			}
		});
	}

	void flip () {
		getFragmentManager ().beginTransaction ()

				.setCustomAnimations (R.animator.card_flip_right_in,
						R.animator.card_flip_right_out,
						R.animator.card_flip_left_in,
						R.animator.card_flip_left_out)

				// Replace any fragments currently in the container view with a
				// fragment
				// representing the next page (indicated by the just-incremented
				// currentPage
				// variable).
				.replace (R.id.container, new CardBackFragment ())

				// Add this transaction to the back stack, allowing users to
				// press Back
				// to get to the front of the card.
				.addToBackStack (null)

				// Commit the transaction.
				.commit ();
	}
}
